home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
SPACE 2
/
SPACE - Library 2 - Volume 1.iso
/
utility
/
528
/
dcoffset
/
dcoffset.doc
Wrap
Text File
|
1989-04-05
|
6KB
|
171 lines
DC Squish is Copyright (c) 1989-91 by Double Click Software.
This document describes and gives sample assembly code for the DC Squish
Offset Protocol which allows programs to save information directly to a
SQUISHed program, without damaging the SQUISHed portion of the program.
What the protocol defines is a region near the beginning of the program
which is not Squished, but merely copied intact. DC Squish v1.4 and above
will automatically detect this protocol and give the user the opportunity
to Squish the program using the protocol, when performing a Squish.
Programs which are Squished will be required to detect that the program is
Squished, when saving information back to itself, and if it is detected,
seek to the unsquished region, then save the necessary information to the
program.
Two sample save routines are included for clarity. They can be used to
detect the DC Squish Offset Protocol.
DC Squish v1.4
==============
Now supports a "protected offset" which can be used to store information
that will not be squished or unsquished - copied only.
Squish Offset Programmer's Reference
------------------------------------
A check of the file to be Squished is made:
TEXT Segment
1) First word = 4EF9 (jmp abs.l)
2) Next long = Offset
3) Next word = Squish cookie.w ($4AFC)
4) Next 8 bytes = User definable
************************
* Sample program start *
************************
BEGIN: jmp (start).l ; jmp non-PC relative!
cookie_sq:dc.w $4afc ; Squish cookie.w
file_info:dc.b 'TEST1234' ; ex. filename (user definable)
cfg_info: ds.l 14 ; configuration info
start:
* Note:
* cfg_info = programmer defined size
* = 128 Kbytes - $1C (program header) - $10 (program start) max.
* ^^^^^^^^^^ (Squish assigned limit)
***********************
* Sample save routine *
***********************
clr.b chk_sqsh
clr.w -(a7) ; mode
pea my_name ; name
move.w #$3d,-(a7)
trap #1 ; Fopen
addq.l #8,a7
move.w d0,f_handle
bmi.s .error
.back pea scratch ; buffer
move.l #cfg_info-BEGIN+$1c,-(a7) ; count
move.w f_handle,-(a7) ; handle
move.w #$3f,-(a7)
trap #1 ; Fread
lea 12(a7),a7
cmp.l d0,d7
bne.s .file_err
move.l 2(a6),d7 ; TEXT (Squish loader) length
moveq #$1c,d0 ; PRG Header length
add.l d0,d7 ; start of Squished file
add.l d0,a6 ; program start (loader)
lea 10(a6),a1 ; Squish check pointer
lea BEGIN,a0
cmp.w (a6)+,(a0)+ ; jmp?
bne.s .chk_sqsh ; nope
addq.l #4,a6 ; skip
addq.l #4,a0 ; offset
cmp.w (a6)+,(a0)+ ; cookie.w?
bne.s .chk_sqsh ; nope
cmp.l (a6)+,(a0)+ ; me1?
bne.s .chk_sqsh ; nope
cmp.l (a6)+,(a0)+ ; me2?
bne.s .chk_sqsh ; nope
pea cfg_info ; buffer
move.l #start-cfg_info,-(a7) ; count
move.w f_handle,-(a7) ; handle
move.w #$40,-(a7)
trap #1 ; Fwrite
lea 12(a7),a7
.file_err move.w f_handle,-(a7)
move.w #$3e,-(a7)
trap #1 ; Fclose
addq.l #4,a7
.out rts
.chk_sqsh move.b chk_sqsh,d0 ; checked Squished?
bne.s .file_err ; yep
cmp.l #'DCSq',(a1) ; Squished?
bne.s .file_err ; nope
clr.w -(a7) ; from beginning
move.w f_handle,-(a7) ; handle
move.l d7,-(a7) ; offset
move.w #$42,-(a7)
trap #1 ; Fseek (Squished file start)
lea 10(a7),a7
cmp.l d7,d0 ; seek error?
bne.s .file_err ; yep
st chk_sqsh
bra.s .back
DATA
my_name: dc.b 'TEST1234.PRG',0
BSS
chk_sqsh: ds.b 1
f_handle: ds.w 1
scratch: ds.b cfg_info-BEGIN
******************************
* Second sample save routine *
******************************
TEXT
my_fseek:
Fseek #$26,d0,#0 ; fseek to 'DCSq' text
Fread temp_fh,#4,#temp_buffer ; read it
cmp.l #'DCSq',temp_buffer ; is it squished?
bne.s .0 ; nope
Fseek #2,temp_fh,#0 ; fseek to 2 from beginning
Fread temp_fh,#4,#temp_buffer ; read text size
add.l #$3c,temp_buffer ; add prog header size
Fseek temp_buffer,temp_fh,#0 ; seek to my data area
rts
.0: ; just seek to prog start
Fseek #$20,temp_fh,#0
rts
*******************************
* save the configuration info *
*******************************
save_info:
bsr my_fseek
Fread temp_fh,#8,#temp_buffer
cmp.l #'TEST',temp_buffer
bne.s .not_my_program
cmp.l #'1234',temp_buffer+4
bne.s .not_my_program
Fwrite temp_fh,#config_size,#config_buffer
moveq #0,d0
rts
.not_my_program:
moveq #-1,d0
rts
BSS
temp_fh:
ds.w 1
temp_buffer:
ds.l 2